<?php

namespace app\admin\model\mechanism;

use app\api\model\v1\UserCheck;
use think\Model;


class Courses extends Model
{

    

    

    // 表名
    protected $name = 'mechanism_courses';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'type_text'
    ];
    

    
    public function getTypeList()
    {
        return ['视频' => __('视频'), '图文' => __('图文')];
    }

    public function getLabelList()
    {
        return ['新职业' => __('新职业'), '精选' => __('精选')];
    }

    public function getIsIndexList()
    {
        return ['0' => __('默认'), '1' => __('推荐')];
    }


    public function getTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
        $list = $this->getTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function check()
    {
        return $this->belongsTo('app\admin\model\user\Check', 'user_check_id', 'id');
    }


}
